<?php
namespace Admin\Controller;
use Think\Controller;
class OrdersController extends Controller {
    public function showList(){
        $list=M('orders')->where("id")->select();
        for($i = 0; $i < count($list); $i ++) { // 有多少审核通过的项目就循环多少次
                $id = $list [$i] ['id'];
                $intro = M('orders')->where ( "id=$id" )->getField ( 'demand' ); // 取出简介

                $str = strip_tags ( $intro ); // 过滤html标签
                $str = str_replace ( " ", "", "$str" ); // 过滤空格
                $result = mb_substr ( $str, 0, 20, 'utf-8' ); // 截取内容
                $list [$i] ['demand'] = $result;
                var_dump($result);
           
        }
        $this->assign('list',$list);
       $this->display();
    }
    function del()
    {
      $id=$_GET['id'];
       $re=M('orders')->where($id)->find();
       var_dump($re["pic"]);
        if ($re["pic"]!="") {
          unlink('./Public/Admin/images/'.$re["pic"]);
           echo "删除成功";

       }
       else{
        echo "删除失败";
       }
       $result=M('orders')->where($id)->delete();
       if ($result!=null) {
           $this->success("删除成功",U('Orders/showList'));
       }
    }
   

}